// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import Promise from 'es6-promise'
window.Promise = Promise
Promise.polyfill()
import "babel-polyfill"
import router from './router'
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import echarts from "echarts";
import axios from 'axios';
import api from '@/api/http.js'
import moment from 'moment'

Vue.prototype.$api = api.admin;
Vue.prototype.$axios = axios;
Vue.prototype.$echarts = echarts;
Vue.prototype.$uploadUrl = 'http://192.168.0.128:8181/AdminAPI/upload/fileUploadToOSS'
// Vue.prototype.$uploadUrl = 'http://192.168.0.152:8181/AdminAPI/upload/fileUploadToOSS'
Vue.config.productionTip = false
Vue.prototype.$moment = moment
Vue.use(ElementUI)

router.beforeEach((to, from, next) => {
  if(to.name != 'login') {
    if(sessionStorage.getItem('token')) {
      next()
    } else {
      next({
        path: '/login'
      })
    }
  } else {
    next()
  }
  
})
export default router
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
